Skip to content

Refactor: replace jean85/pretty-package-versions with native Composer\InstalledVersions - #1047

Open
peter17 wants to merge 1 commit into
getsentry:masterfrom
peter17:patch1
Open

Refactor: replace jean85/pretty-package-versions with native Composer\InstalledVersions#1047
peter17 wants to merge 1 commit into
getsentry:masterfrom
peter17:patch1

Conversation

@peter17

@peter17 peter17 commented Jul 28, 2026

Copy link
Copy Markdown

Description

Now that Composer 2 is standard across all supported environments, we can rely on Composer's native Composer\InstalledVersions API (composer-runtime-api: ^2.0) provided directly by Composer itself.

Previously, jean85/pretty-package-versions served as a helpful compatibility layer during the Composer 1 era. With Composer 2 ubiquity, shifting to native Composer runtime APIs allows us to:

  • Reduce our overall dependency graph and external package footprint.
  • Align with security best practices by favoring official core/organization-maintained APIs (composer/composer) directly where built-in capabilities exist, minimizing potential supply-chain surface area.
  • Remove outdated plugin permissions (composer/package-versions-deprecated).

Changes

  • Replaced jean85/pretty-package-versions dependency with "composer-runtime-api": "^2.0" in composer.json.
  • Updated SentryExtension and SentryExtensionTest to use Composer\InstalledVersions::getRootPackage()['pretty_version'].
  • Cleaned up obsolete plugin permissions from composer.json.

Verification

  • composer cs-check passed
  • composer tests (PHPUnit suite) passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b8ef45f. Configure here.


if (!$container->hasParameter('env(SENTRY_RELEASE)')) {
$container->setParameter('env(SENTRY_RELEASE)', PrettyVersions::getRootPackageVersion()->getPrettyVersion());
$container->setParameter('env(SENTRY_RELEASE)', InstalledVersions::getRootPackage()['pretty_version']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev release version loses commit hash

Medium Severity

PrettyVersions::getPrettyVersion() appended a short commit reference for non-tagged packages (e.g. dev-main@7cd88c8), but InstalledVersions::getRootPackage()['pretty_version'] returns only the branch name. When release and SENTRY_RELEASE are unset, branch-based deploys now share one Sentry release identifier, weakening release tracking and suspect commits.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b8ef45f. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true but I believe it is no relevant in the current context, because it just fetches the root package version as a fallback if there is no SENTRY_RELEASE env variable defined. If it is really an issue, I think we can preserve the previous behavior by using the root package reference when available and appending its short SHA (e.g. dev-main@7cd88c8). That keeps the dependency removal while maintaining unique release identifiers for branch-based deployments.

$rootPackage = InstalledVersions::getRootPackage();
$release = $rootPackage['pretty_version'];
if (
    isset($rootPackage['reference'])
    && $rootPackage['reference'] !== null
    && str_starts_with($release, 'dev-')
) {
    $release .= '@' . substr($rootPackage['reference'], 0, 7);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant